package com.example.sunjian.myapplication.event_dispatch;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.LinearLayout;

/**
 * 作者：sunjian on 16/6/6 17:34
 * 邮箱：sunjian@cyhz.com
 */
public class CustomViewGroup extends LinearLayout {


    public CustomViewGroup(Context context) {
        super(context);
    }

    public CustomViewGroup(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public CustomViewGroup(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }


    /***
     *
     * @param ev
     * @return
     */
    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {

        switch (ev.getAction()){

            case MotionEvent.ACTION_DOWN:

                Log.e("sj","dispatchTouchEvent  ACTION_DOWN");

                break;

            case MotionEvent.ACTION_MOVE:

                Log.e("sj","dispatchTouchEvent  ACTION_MOVE");

                break;

            case MotionEvent.ACTION_UP:

                Log.e("sj","dispatchTouchEvent  ACTION_UP");

                break;
        }

        return super.dispatchTouchEvent(ev);
    }


    @Override
    public boolean onTouchEvent(MotionEvent event) {

        switch (event.getAction()){

            case MotionEvent.ACTION_DOWN:

                Log.e("sj","onTouchEvent  ACTION_DOWN");

                break;

            case MotionEvent.ACTION_MOVE:

                Log.e("sj","onTouchEvent  ACTION_MOVE");

                break;

            case MotionEvent.ACTION_UP:

                Log.e("sj","onTouchEvent  ACTION_UP");

                break;
        }

        return super.onTouchEvent(event);
    }
}
